package com.zoke.tint.activities;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import com.larswerkman.holocolorpicker.ColorPicker;
import com.larswerkman.holocolorpicker.OpacityBar;
import com.larswerkman.holocolorpicker.SVBar;
import com.larswerkman.holocolorpicker.SaturationBar;
import com.larswerkman.holocolorpicker.ValueBar;
import com.zoke.tint.BaseActivity;
import com.zoke.tint.R;
import com.zoke.tint.helper.TintManager;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

/**
 * @author 大熊 QQ:651319154
 */
@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity implements ColorPicker.OnColorChangedListener, ColorPicker.OnColorSelectedListener {
    @ViewInject(R.id.toolbar)
    private Toolbar mToolbar;

    @ViewInject(R.id.themeIv)
    private ImageView themeIv;
    @ViewInject(R.id.themeTv)
    private TextView themeTv;
    @ViewInject(R.id.homeIv)
    private ImageView homeIv;
    @ViewInject(R.id.homeTv)
    private TextView homeTv;
    @ViewInject(R.id.frIv)
    private ImageView frIv;
    @ViewInject(R.id.frTv)
    private TextView frTv;

    @ViewInject(R.id.picker)
    private ColorPicker picker;

    @ViewInject(R.id.svbar)
    private SVBar svbar;
    @ViewInject(R.id.opacitybar)
    private OpacityBar opacitybar;
    @ViewInject(R.id.saturationbar)
    private SaturationBar saturationBar;
    @ViewInject(R.id.valuebar)
    private ValueBar valueBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mToolbar.setTitle("图标变色");
        setSupportActionBar(mToolbar);
        //设置初始值
        picker.setColor(getResources().getColor(R.color.colorPrimary));
        picker.setOnColorChangedListener(this);
        picker.setOnColorSelectedListener(this);
        picker.addSVBar(svbar);
        picker.addOpacityBar(opacitybar);
        picker.addSaturationBar(saturationBar);
        picker.addValueBar(valueBar);
    }

    @Override
    public void onColorChanged(int color) {
        mToolbar.setBackgroundColor(color);
        getStatusBar().setBackgroundColor(color);
        TintManager.setTint(themeIv, color);
        TintManager.setTint(homeIv, color);
        TintManager.setTint(frIv, color);
        themeTv.setTextColor(color);
        homeTv.setTextColor(color);
        frTv.setTextColor(color);
    }


    @Override
    public void onColorSelected(int color) {

    }
}
